/************************************
 * Package: RGcpp					*
 * Authors: Rui Eduardo Gouveia Gil	*
 * Date: 2010						*
 ************************************/
#ifndef __RGCPP_EXCEPTIONHANDLER_H__
#define __RGCPP_EXCEPTIONHANDLER_H__

#include <string>
#include <sstream>
#include <iostream>

#ifdef _WIN32
#else
#include <signal.h>
#include <stdlib.h>
#include <cxxabi.h>
#include <execinfo.h>
#endif

namespace rgcpp
{

#define MAX_STACKTRACE_NAME 256
#define MAX_STACKTRACE_FRAMES 128

class ExceptionHandler
{
	private:
		static ExceptionHandler* exceptionHandlerPtr;

	public:
		~ExceptionHandler();

		static void CreateExceptionHandler();
		static std::string getStackTraceString();
		static void DestroyExceptionHandler();

	private:
		ExceptionHandler();

		static void signalHandler(int signal);
};

}

#endif
